package com.longteng.lesson2.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class ViewController {

    @RequestMapping("/view")
    public String view(Model model){
        model.addAttribute("name","哈哈 我是后端返回的数据");
        return "view";
    }

    @RequestMapping("/modelAndView")
    public ModelAndView modelAndView(){
        ModelAndView modelAndView =new ModelAndView();
        modelAndView.setViewName("view");
        modelAndView.addObject("name","哈哈哈 我是modelAndView");
        return modelAndView;
    }
}
